package com.infore.siteManagement.repository;

import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import com.infore.siteManagement.entity.StationAndApp;

@Repository
public interface IStationAndAppRepository extends JpaRepository<StationAndApp, String>,
JpaSpecificationExecutor<StationAndApp>{

	@Modifying
	@Transactional
	@Query(value="delete from STATION_AND_APP where STATION_ID in(:ids)",nativeQuery=true)
	int delByStationIdIn(@Param("ids") List<String> ids);
	
	@Modifying
	@Transactional
	@Query(value="delete from STATION_AND_APP where STATION_ID =:id and APP_CODE = :appCode",nativeQuery=true)
	int delByStationIdAndPlat(@Param("id") String id,@Param("appCode") String appCode);
	
	List<StationAndApp> findByAppCode(String appCode);
	
	@Query(value="select STATION_ID from STATION_AND_APP where APP_CODE = :appCode",nativeQuery=true)
	List<String> queryStationByAppCpde(@Param("appCode")String appCode);
}
